<?

$large_image_prefix = "o_"; 			// The prefix name to large image
$thumb_image_prefix = "x_";			// The prefix name to the thumb image

if (isset($_POST["upload"]) && isset($_FILES['image']['name'])) { 
	
	$image = new Image('file', $_FILES['image'], array(
	'maxWidth' => 500, 
	'newExtension' => 'jpg', 
	'folder' => ABSPATH."images/events/", 
	'imageName' =>$idEvent, 
	'deleteOnChange' => false), null);
	$image->addArrSize(0, 0, 'o_'); 
	
	$image->save();
}

if (isset($_POST["upload_thumbnail"]) && $large_photo_exists) {
	//Get the new coordinates to crop the image.
	$x1 = $_POST["x1"];
	$y1 = $_POST["y1"];
	$x2 = $_POST["x2"];
	$y2 = $_POST["y2"];
	$w = $_POST["w"];
	$h = $_POST["h"];

	$image = new Image('file', array(), array(
	'folder' => ABSPATH."images/events/", 
	'allowEmpty' => true,
	'imageName' => $idEvent, 
	'imageType' => 'jpg', 
	'deleteOnChange' => false), null);
	$image->addArrCut($thumb_width, $thumb_height, 'x_', $x1, $y1, $w, $h); 
	$image->addArrCut(100, 75, 'header_', $x1, $y1, $w, $h);
	
	$image->save();
	
//	header('Location: '.W_ABSPATH.'profile');

	$rnd = true;
}

?>